Financial Analysis On US Financial Data¶

The financial dataset of the USA TOP15 companies between 2014 and 2018 was analyzed to gain insights into their performance during this period. The dataset includes important financial indicators such as revenue, net income, EBITDA, profit margin, gross profit, and operating income. The analysis involved visualizing the trends of these indicators over the years, identifying the best-performing companies, and comparing their financial performance. The project aimed to provide investors and stakeholders with valuable information to make informed decisions on investment opportunities in the top-performing companies. Overall, the analysis showed a positive trend in the financial performance of these companies, with some companies performing better than others in certain indicators.

Data Source¶

The dataset was obtained from Kaggle. The dataset contains the financial data of the top 15 companies in the USA between 2014 and 2018. The dataset contains the following columns:

Importing the libraries¶

In [1]:
import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')

Importing the dataset¶

In [2]:
df_2014 = pd.read_csv('2014_Financial_Data.csv')
df_2015 = pd.read_csv('2015_Financial_Data.csv')
df_2016 = pd.read_csv('2016_Financial_Data.csv')
df_2017 = pd.read_csv('2017_Financial_Data.csv')
df_2018 = pd.read_csv('2018_Financial_Data.csv')

Data Preprocessing and Analysis¶

In [3]:
print("Shape df_2014: {}".format(df_2014.shape))
print("Shape df_2015: {}".format(df_2015.shape))
print("Shape df_2016: {}".format(df_2016.shape))
print("Shape df_2017: {}".format(df_2017.shape))
print("Shape df_2018: {}".format(df_2018.shape))
Shape df_2014: (3808, 225)
Shape df_2015: (4120, 225)
Shape df_2016: (4797, 225)
Shape df_2017: (4960, 225)
Shape df_2018: (4392, 225)
In [4]:
print(df_2014.info())
print('------------------------------------')
print(df_2015.info())
print('------------------------------------')
print(df_2016.info())
print('------------------------------------')
print(df_2017.info())
print('------------------------------------')
print(df_2018.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3808 entries, 0 to 3807
Columns: 225 entries, Unnamed: 0 to Class
dtypes: float64(222), int64(1), object(2)
memory usage: 6.5+ MB
None
------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4120 entries, 0 to 4119
Columns: 225 entries, Unnamed: 0 to Class
dtypes: float64(222), int64(1), object(2)
memory usage: 7.1+ MB
None
------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4797 entries, 0 to 4796
Columns: 225 entries, Unnamed: 0 to Class
dtypes: float64(222), int64(1), object(2)
memory usage: 8.2+ MB
None
------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4960 entries, 0 to 4959
Columns: 225 entries, Unnamed: 0 to Class
dtypes: float64(222), int64(1), object(2)
memory usage: 8.5+ MB
None
------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4392 entries, 0 to 4391
Columns: 225 entries, Unnamed: 0 to Class
dtypes: float64(222), int64(1), object(2)
memory usage: 7.5+ MB
None
In [5]:
df_2014.fillna(0,inplace=True)
df_2015.fillna(0,inplace=True)
df_2016.fillna(0,inplace=True)
df_2017.fillna(0,inplace=True)
df_2018.fillna(0,inplace=True)

df_2014['Date'] = "2014"
df_2015['Date'] = "2015"
df_2016['Date'] = "2016"
df_2017['Date'] = "2017"
df_2018['Date'] = "2018"

df_2014.set_index('Date', inplace=True)
df_2015.set_index('Date', inplace=True)
df_2016.set_index('Date', inplace=True)
df_2017.set_index('Date', inplace=True)
df_2018.set_index('Date', inplace=True)
In [6]:
years = ["2014", "2015", "2016", "2017", "2018"]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'UNH', 'AMZN']

dfs = {}
for year in years:
    df_year = globals()['df_' + str(year)]
    for company in companies:
        dfs[f"{year}_{company}"] = df_year[df_year['Unnamed: 0'] == company]

for company in companies:
    df_list = [dfs[f"{year}_{company}"] for year in years]
    df = pd.concat(df_list, axis=0)
    df.drop('Unnamed: 0', axis=1, inplace=True)
    globals()[company] = df
In [7]:
df_list = [AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, UNH, AMZN]
companies = ['AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'UNH', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    df['quickRatio'].plot.bar()
    plt.xlabel('Years')
    plt.ylabel('Quick Ratio')
    plt.title(f'Quick Ratio analysis for {companies[i]}')
    plt.grid(True)
    plt.show()
In [8]:
df_list = [AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, UNH, AMZN]
companies = ['AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'UNH', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    df['currentRatio'].plot.bar()
    plt.xlabel('Years')
    plt.ylabel('Current Ratio')
    plt.title(f'Current Ratio analysis for {companies[i]}')
    plt.grid(True)
    plt.show()
In [9]:
df_list = [WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, UNH, AMZN]
companies = ['WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'UNH', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    df['debtEquityRatio'].plot.bar()
    plt.xlabel('Years')
    plt.ylabel('Debt Equity Ratio')
    plt.title(f'Debt Equity Ratio analysis for {companies[i]}')
    plt.grid(True)
    plt.show()
In [10]:
df_list = [AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    df['inventoryTurnover'].plot.bar()
    plt.xlabel('Years')
    plt.ylabel('Inventory Turnover')
    plt.title(f'Inventory Turnover analysis for {companies[i]}')
    plt.grid(True)
    plt.show()
In [11]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, UNH, AMZN]

for df in df_list:
    df['ShortTermAssets'] = df['Cash and cash equivalents'] + df['Cash and short-term investments'] + df['Inventories'] + df['Average Receivables'] + df['Investments'] + df['Investment purchases and sales'] + df['Short-term investments']
    df['liquidcash'] = df['Cash and cash equivalents'] + df['Cash and short-term investments']
    df['LongTermAsset'] = df['Property, Plant & Equipment Net'] +df['Goodwill and Intangible Assets']+df['Long-term investments']
    df['TotalAssets'] = df['ShortTermAssets'] + df['LongTermAsset']
In [12]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['ShortTermAssets'], label='Short Term Assets')
    plt.plot(df.index, df['liquidcash'], label='Liquid Cash')
    plt.plot(df.index, df['LongTermAsset'], label='Long Term Assets')
    plt.plot(df.index, df['TotalAssets'], label='Total Assets')
    plt.plot(df.index, df['Total non-current assets'], label='Total Assets (Reported)')
    plt.xlabel('Years')
    plt.ylabel('Assets Value')
    plt.title(f'Assets analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()
In [13]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['Short-term debt'], label='Short Term Debt')
    plt.plot(df.index, df['Long-term debt'], label='Long Term Debt')
    plt.plot(df.index, df['Total debt'], label='Total Debt')
    plt.xlabel('Years')
    plt.ylabel('Debt Value')
    plt.title(f'Debt analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()
In [14]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['Total liabilities'], label='Total liabilities')
    plt.plot(df.index, df['Total non-current liabilities'], label='Total non-current liabilities')
    plt.plot(df.index, df['Total current liabilities'], label='Total current liabilities')
    plt.xlabel('Years')
    plt.ylabel('Liabilities Value')
    plt.title(f'Liabilities analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()
In [15]:
for df in df_list:
    df['Total Investments'] = df['Investments'] + df['Investment purchases and sales'] + df['Long-term investments'] + df['Short-term investments']
In [16]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['Short-term investments'], label='Short-term investments')
    plt.plot(df.index, df['Cash and short-term investments'], label='Cash and short-term investments')
    plt.plot(df.index, df['Long-term investments'], label='Long-term investments')
    plt.plot(df.index, df['Investments'], label='Investments')
    plt.plot(df.index, df['Investment purchases and sales'], label='Investment purchases and sales')
    plt.plot(df.index, df['Total Investments'], label='Total Investments')
    plt.xlabel('Years')
    plt.ylabel('Investments Value')
    plt.title(f'Investments analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()
In [17]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['Net Income'], label='Net Income')
    plt.plot(df.index, df['Operating Income'], label='Operating Income')
    plt.plot(df.index, df['Operating Expenses'], label='Operating Expenses')
    plt.xlabel('Years')
    plt.ylabel('Income Value')
    plt.title(f'Income analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()
In [18]:
df_list = [KST, AMX, WMT, SNP, XOM, PTR, BP, TM, TOT, CVX, AAPL, MCK, AMZN]
companies = ['KST', 'AMX', 'WMT', 'SNP', 'XOM', 'PTR', 'BP', 'TM', 'TOT', 'CVX', 'AAPL', 'MCK', 'AMZN']
for i, df in enumerate(df_list):
    plt.figure(figsize=(6,3))
    plt.plot(df.index, df['EBITDA'], label='EBITDA')
    plt.plot(df.index, df['Profit Margin'], label='Profit Margin')
    plt.plot(df.index, df['EBIT'], label='EBIT')
    plt.plot(df.index, df['Gross Profit'], label='Gross Profit')
    plt.xlabel('Years')
    plt.ylabel('Profit Value')
    plt.title(f'Profit analysis for {companies[i]}')
    plt.legend(fontsize=5)
    plt.grid(True)
    plt.show()